<?
/* $Id: msg.php 61 2011-02-22 16:54:49Z jim2212001@gmail.com $ */
if(!defined('WEBHOME'))
	die ('DO NOT EXECUTE THIS FILE');
define(MSG_UNKNOW_ACTION,'未知動作');
define(MSG_PERMISSION_DENIED,'權限不足');
define(MSG_FORMAT_ERROR,'格式錯誤');
define(MSG_MYSQL_ERROR,'MySQL伺服器發生錯誤');
/* login.php */
define(MSG_LOGIN_DEFAULT,'登入失敗');
define(MSG_LOGIN_PLEASELOGIN,'請先登入');
define(MSG_LOGIN_SUCCESS,'已登入');
define(MSG_LOGIN_LOGOUT,'已登出');
define(MSG_LOGIN_FAIL,'帳號密碼錯誤');
define(MSG_LOGIN_VALIDFAIL,'驗證失敗');
define(MSG_LOGIN_CANCEL,'已取消登入');
define(MSG_LOGIN_NOTSUPPORT,'尚未支援此登入方式');
/* panel.php */
/* editlist */
define(MSG_PANEL_EDITLIST_NOTFOUND,'未找到此專案');
define(MSG_PANEL_EDITLIST_DELETEFAIL,'刪除失敗');
define(MSG_PANEL_EDITLIST_DELETED,'已刪除');
/* booklist.php */
define(MSG_BOOKLIST_READONLY,'你沒有訂購此書單的權限，只能檢視書單');
define(MSG_BOOKLIST_ORDERLISTNOTFOUND,'未找到此訂單');
define(MSG_BOOKLIST_NOTACTIVE,'現在不是此訂單的開放時間');

function debugMsg($format){
	if(DEBUG){
		$args=func_get_args();
		array_shift($args);
		vprintf($format,$args);
	}
}
function adminMsg($format){
	if(isAdmin()){
		$args=func_get_args();
		array_shift($args);
		vprintf($format,$args);
	}
}
function infoMsg($msg,$blankPage=false){
	$GLOBALS['_infoMsg'][]=$msg;
	if($blankPage){
		header('Location: message.php?action=info&reason='.urlencode($msg));
		exit;
	}
}
function errMsg($msg,$blankPage=false){
	$GLOBALS['_errorMsg'][]=$msg;
	if($blankPage){
		header('Location: message.php?action=error&reason='.urlencode($msg));
		exit;
	}
}
function redirectMsg($page){
	$typeArray=array('info','error');
	foreach($typeArray as $type){
	  	if(!isset($GLOBALS['_'.$type.'Msg']))
		  	continue;
		foreach($GLOBALS['_'.$type.'Msg'] as $value){
			$_SESSION['_msg'][]=array('type'=>$type,'reason'=>$value);
		}
	}
	header('Location: '.$page);
	exit;
}
function hasErr(){
	return count($GLOBALS['_errorMsg']);
}
?>
